import {createRouter, createWebHistory} from 'vue-router'

// createRouter 创建路由实例，===> new VueRouter()
// 1. history模式: createWebHistory()   http://xxx/user
// 2. hash模式: createWebHashHistory()  http://xxx/#/user
// vite 的配置 import.meta.env.BASE_URL 是路由的基准地址，默认是 ’/‘
// https://vitejs.dev/guide/build.html#public-base-path
// 如果将来你部署的域名路径是：http://xxx/my-path/user
// vite.config.ts  添加配置  base: my-path，路由这就会加上 my-path 前缀了
const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {path: '/login', component: () => import('@/views/login/LoginPage.vue')}, // 登录页
        {
            path: '/',
            component: () => import('@/views/layout/LayoutContainer.vue'),
            redirect: '/article/channel',
            children: [
                {
                    path: '/article/channel',
                    component: () => import('@/views/article/ArticleChannel.vue')
                }, {
                    path: '/article/manage',
                    component: () => import('@/views/article/ArticleManage.vue')
                }, {
                    path: '/user/profile',
                    component: () => import('@/views/user/UserProfile.vue')
                },
                {
                    path: '/user/avatar',
                    component: () => import('@/views/user/UserAvatar.vue')
                },
                {
                    path: '/user/password',
                    component: () => import('@/views/user/UserPassword.vue')
                }
            ]
        }
    ]
})

export default router
